var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var BundleConfig = require("AA_BundleConfig");
var ADManager = require("AA_ADManager");
var EventManager = require("AA_EventManager");
var TipsManager = require("AA_TipsManager");
var UIManager = require("AA_UIManager");
var UIView = require("AA_UIView");
var EvenType = require("AA_EvenType");
var PlayerDataManager = require("AA_PlayerDataManager");
var Excel = require("AA_Excel");
var Const_Hall = require("AA_Const_Hall");
var HallGlobalVariable = require("AA_HallGlobalVariable");
var UIConfig_Home = require("AA_UIConfig_Home");
var UI_QianDaoItem = require("AA_UI_QianDaoItem");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
var _property = _decorator.property;

var _def_UI_QianDao = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.content = null;
    t.state1 = null;
    t.state2 = null;
    return t;
  }
  __extends(_creator, e);
  _creator.prototype._show = function (e) {
    var t = [];
    for (var o = 1; o < arguments.length; o++) {
      t[o - 1] = arguments[o];
    }
    PlayerDataManager.PlayerDataMgr.resetQianDaoCount();
    this.initQianDao();
  };
  _creator.prototype.initQianDao = function () {
    var e = Excel.Excel.shuiguoqiandao_all.size;
    var t = this.content.children;
    var o = function (e) {
      var o = Excel.Excel.shuiguoqiandao(e + 1);
      var i = t[e];
      if (!i) {
        i = cc.instantiate(t[0]);
        n.content.addChild(i);
      }
      n.scheduleOnce(function () {
        i.getComponent(UI_QianDaoItem.default).initUi(o);
      });
    };
    var n = this;
    for (var i = 0; i < e; i++) {
      o(i);
    }
    if (1 == PlayerDataManager.PlayerDataMgr.globalData.isqiandaocode && PlayerDataManager.PlayerDataMgr.globalData.qiandaocount < 9) {
      this.state1.active = true;
      this.state2.active = false;
    } else {
      this.state1.active = false;
      this.state2.active = true;
    }
  };
  _creator.prototype.onLinQu = function (e, t) {
    undefined === t && (t = 1);
    var o = this.content.children;
    var n = null;
    for (var i = 0; i < o.length; i++) {
      var a = o[i].getComponent(UI_QianDaoItem.default);
      if (1 == a.nowcode) {
        n = a.nowqiandao;
        break;
      }
    }
    var r = n.award * t;
    PlayerDataManager.PlayerDataMgr.setQianDaoState();
    var s = null;
    var p = new Const_Hall.GetItemsData();
    p.ids = [];
    p.counts = [];
    switch (n.awardtype) {
      case 1:
        p.ids.push(HallGlobalVariable.default.goldId);
        p.counts.push(r);
        break;
      case 2:
        p.ids.push(HallGlobalVariable.default.diamondId);
        p.counts.push(r);
        break;
      case 3:
        p.ids.push(HallGlobalVariable.default.powerId);
        p.counts.push(r);
        break;
      case 5:
        s = HallGlobalVariable.default.GetSuiPian([r, 0, 0]);
        break;
      case 6:
        s = HallGlobalVariable.default.GetSuiPian([0, r, 0]);
        break;
      case 7:
        s = HallGlobalVariable.default.GetSuiPian([0, 0, r]);
    }
    s && s.forEach(function (e, t) {
      p.ids.push(t);
      p.counts.push(e);
    });
    UIManager.default.open(BundleConfig.BundleNames.Home, UIConfig_Home.UIView_Home.UI_GetItems, p);
    p.clickCallBack = function () {
      for (var e = 0; e < p.ids.length; e++) {
        var t = p.ids[e];
        var o = p.counts[e];
        switch (t) {
          case HallGlobalVariable.default.goldId:
            EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Home_Add_Gold, 2, o);
            break;
          case HallGlobalVariable.default.diamondId:
            EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Home_Add_Gold, 3, o);
            break;
          case HallGlobalVariable.default.powerId:
            EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Home_Add_Gold, 1, o);
            break;
          default:
            TipsManager.TipMgr.showToast("恭喜获得水果碎片");
            PlayerDataManager.PlayerDataMgr.AddEquipFragments(t, o);
        }
      }
    };
    this.onCloseQianDao();
  };
  _creator.prototype.onDoubelLinQu = function () {
    var e = this;
    ADManager.ADMgr.showRewardedVideo("双倍签到", function () {
      e.onLinQu(null, 2);
    });
  };
  _creator.prototype.onCloseQianDao = function () {
    this._close();
  };
  __decorate([_property(cc.Node)], _creator.prototype, "content", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "state1", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "state2", undefined);
  return __decorate([_ccclass], _creator);
}(UIView.default);
exports.default = _def_UI_QianDao;